var net = require('net');
var events = require('events');
var channel = new events.EventEmitter();
channel.clients = {};
channel.subscriptions = {};

channel.on('join',function(id, client){
	console.log(id+"加入进来了");
});

var server =  net.createServer(function(client){
	var id = client.remoteAddress + ":" + client.remotePort;
	channel.emit('join',id,client);
	client.on('data',function(data){
		console.log(data);
	});
	client.on('close',function(err){
		console.log('closed');
	});
});


server.listen(3490,function(err){
	console.log('server start on port 3490')
});



